/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1637825072263_7631';

  // 中间件加载
  config.middleware = ['init', 'errorHanlder', 'token', 'requier'];
  config.token = {
    ignore: ['/reg', '/User/login'] // tonke校验忽略注册和登陆的接口
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  //mysql数据连接配置
  config.mysql = {
    client: {
      host: 'localhost',
      port: '3306',
      user: 'egg',
      password: '123456',
      database: 'eggDemo'
    },
    //load into app,default is open //加载到应用程序，默认为打开
    app: true,
    //load into agent,default is close //加载到代理中，默认值为“关闭”
    agent: false,
  };
  // session 配置
  config.session = {
    key: 'EGG_SESS',  //eggjs默认session的key
    maxAge: 24 * 3600 * 1000,  // 1 day
    httpOnly: true,
    encrypt: true,
    renew: true  //每次访问页面都会给session会话延长时间
  };
  // 针对egg的安全策略，过滤以下接口不用提交x-csrf-token
  config.security = {
    csrf: {
      ignore: '/User/login',
      enable: false
    },
  };
  //jwt的配置
  config.jwt = {
    key: 'dwanliang120',
  };

  return {
    ...config,
    ...userConfig,
  };
};
